<?php

/**
 * Camioneta form.
 *
 * @package    cronos-doctrine
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class CamionetaForm extends BaseCamionetaForm
{
  public function configure()
  {
      unset(
          $this['created_at'],
          $this['updated_at'],
          $this['area_id']
      );
      
      $this->widgetSchema['nombre'] = new sfWidgetFormInputText(array(),array('placeholder'=>'Nombre Unidad'));
      $operadores = new sfGuardUser();
        $this->widgetSchema['operador_id'] = new sfWidgetFormDoctrineChoice(array(
        'model' => 'SfGuardUser',
        'key_method'=>'getId',
        'query' => $operadores->getOperador(),

        ));
      
//SUGERENCIAS DE LLENADO DE FORMULARIO CAMIONETA NUEVA
        
      $this->widgetSchema['telefono'] = new sfWidgetFormInputText(array(),array('placeholder'=>'5555555555'));
      $this->widgetSchema['seguro_telefono'] = new sfWidgetFormInputText(array(),array('placeholder'=>'018001234567'));
      $this->widgetSchema['marca'] = new sfWidgetFormInputText(array(),array('placeholder'=>'P.Ej. Nissan'));
      $this->widgetSchema['modelo'] = new sfWidgetFormInputText(array(),array('placeholder'=>'P.Ej.Chasis Largo'));
      $this->widgetSchema['placa'] = new sfWidgetFormInputText(array(),array('placeholder'=>'123ABC'));
      $this->widgetSchema['serie'] = new sfWidgetFormInputText(array(),array('placeholder'=>'17#MAYUSCULAS'));
      $this->widgetSchema['seguro'] = new sfWidgetFormInputText(array(),array('placeholder'=>'No. de Poliza'));
      $this->widgetSchema['empresa_id'] = new sfWidgetFormInputHidden(array(),array('value'=> sfContext::getInstance()->getUser()->getAttribute('agente_user_empresa_id')));
      
      
      
        $this->widgetSchema['categoria_list'] = new sfWidgetFormDoctrineChoice(array(
         'multiple' => false, 
         'model' => 'Categoria',
         'query' => Doctrine_Query::create()->select('c.id,t.nombre')
                                    ->from('Categoria c')
                                    ->leftJoin('c.Translation t')
                                    ->where('c.status = ?', '1')
                                    ->addWhere('c.padre IS NULL ')
                                    ->andWhere('t.lang = ?', sfContext::getInstance()->getUser()->getCulture())
                                    ->orderBy('t.nombre ASC'),
         'expanded' => false));
       
      
      $this->widgetSchema['categoria_list']->setOption('renderer_class', 'sfWidgetFormSelectDoubleList');
      $this->widgetSchema['categoria_list']->setLabel('Servicios');
 
      
      
      
//Cambiar a lista y su validador de los status Activo e Inativo 0/1
      $this->widgetSchema['status'] = new sfWidgetFormChoice(array(
         'choices' => Camioneta::$status,
         'expanded' => false,
         'multiple' => false,
          
       ));
      
//Cambiar a lista y su validador si es franqqucia Activo e Inativo 0/1
      $this->widgetSchema['is_franquicia'] = new sfWidgetFormChoice(array(
         'choices' => Camioneta::$is_franquicia,
         'expanded' => false,
         'multiple' => false,
          
       )); 
      
      
// LLENADO AÑOS MODELOS DE UN ANIO POSTERIOR a 12 ANYOS ATRAS
       
       $aniosarray = array();
       $aniomasreciente = date('Y')+1;
       
       for($anios = $aniomasreciente; $anios > ($aniomasreciente-12);$anios--)
          $aniosarray[$anios]= $anios;
          
      
      
      $this->widgetSchema['anio'] = new sfWidgetFormChoice(array(
         'choices' => $aniosarray,
         'expanded' => false,
         'multiple' => false,

      ));

      $this->validatorSchema['status'] = new sfValidatorChoice(array(
          'choices' => array_keys(Camioneta::$status),

      ));
      
      $this->widgetSchema['fecha_verificacion'] = new sfWidgetFormJQueryDate(array(
         'culture'=> 'es',         
         'config' => "{minDate: +1}"         
         ));
      
      $this->widgetSchema['seguro_vencimiento'] = new sfWidgetFormInput(array(), array('size' => 15, 'id' => 'fechaDashboard', 'readonly'=>'readonly'));
      
      
  }
}
